<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link th:href="@{/css/style.css}" rel="stylesheet" type="text/css"/>
    <th:block th:include="public::common-script"></th:block>
    <script th:src="@{/layer/layer.js}" type="text/javascript"></script>
    <style>
        [name=subject] {
            position: relative;
            top: 2px;
        }

        .mli {
            width: 60px !important;
        }
    </style>
</head>

<body th:if="${clazzList.size()>0}">

<div class="place">
    <span>位置：</span>
    <ul class="placeul">
        <li><a href="#">我的班级</a></li>
        <li><a href="#">考试发布</a></li>
    </ul>
</div>

<div class="formbody">

    <div class="formtitle"><span>班级考试发布</span></div>

    <ul class="forminfo">
        <li>
            <label>考试班级</label>
            <select name="clazzId" type="text" class="dfinput" onchange="change()"/>
            <option
                    th:each="clazzItem:${clazzList}"
                    th:text="${clazzItem.created+'级'+clazzItem.name}"
                    th:value="${clazzItem.id}"
            ></option>
            </select>
        </li>
        <li>
            <label>学年</label>
            <select name="xn" type="text" class="dfinput" onchange="change()"/>
            <option value="上半学期">上半学期</option>
            <option value="下半学期">下半学期</option>
            </select>
        </li>
        <li>
            <label>考试名称</label><input name="name" type="text"
                                      th:value="${clazzList.get(0).created+'级'+clazzList.get(0).name+'上半学期第一次班级模拟考试'}"
                                      class="dfinput"/>
            <i>仅供参考</i>
        </li>
        <li><label>&nbsp;</label><input name="" onclick="save()" type="button" class="btn"
                                        value="确认发布"/></li>
    </ul>
</div>
<script type="text/javascript" th:inline="javascript">
    function change() {
        var text = $("[name=clazzId] option:selected").text();
        var xq = $("[name=xn] option:selected").text();
        $("[name=name]").val(text + xq + '第一次班级模拟考试')
    }

    function save() {
        var name = $("[name=name]").val();
        var clazzId = $("[name=clazzId]").val();
        var xn = $("[name=xn]").val();
        if (name == "") {
            layer.msg('请输入考试名称', {icon: 5});
            return false;
        }
        // /teacher/addExamInfo
        $.get("/teacher/addExamInfo", {
            name: name,
            clazzId: clazzId,
        }, function (resp) {
            if (resp.code == 200) {
                layer.msg('发布成功', {icon: 1});
            }
        })
    }
</script>
</body>
<body th:if="${clazzList.size()==0}">
<center>
    <p style="margin: 200px auto 0;text-align: center;font-size: 48px;color: red;">无法发布考试信息</p>
    <p style="margin: 20px auto 0;text-align: center;font-size: 16px;color: #d3d3d3;">
        可能的原因：你还不是任何班级的班主任。只有班主任才可以发布班级考试信息！</p>
</center>
</body>
</html>
